import request from '@/utils/request'

export default {
  /*
  DELETE /admin/acl/user/batchRemove
  根据id列表删除管理用户

  POST /admin/acl/user/doAssign
  根据用户分配角色

  GET /admin/acl/user/get/{id}
  获取管理用户

  DELETE /admin/acl/user/remove/{id}
  删除管理用户

  POST /admin/acl/user/save
  新增管理用户

  GET /admin/acl/user/toAssign/{userId}
  根据用户获取角色数据

  PUT /admin/acl/user/update
  修改管理用户

  GET /admin/acl/user/{page}/{limit}
  获取管理用户分页列表
  */
  getUserList(page, limit, username) {
    if (username) {
      return request.get(`/admin/acl/user/${page}/${limit}?username=${username}`)
    } else {
      return request.get(`/admin/acl/user/${page}/${limit}`)
    }
  },

  updateUser(userInfo) {
    return request.put('/admin/acl/user/update', userInfo)
  },

  getRoleInfoByUserId(userId) {
    return request.get(`/admin/acl/user/toAssign/${userId}`)
  },

  addUser(userInfo) {
    return request.post('/admin/acl/user/save', userInfo)
  },

  deleteUser(userId) {
    return request.delete(`/admin/acl/user/remove/${userId}`)
  },

  getUserByUserId(userId) {
    return request.get(`/admin/acl/user/get/${userId}`)
  },

  doAssign(userId, roleIds) {
    return request.post(`/admin/acl/user/doAssign?userId=${userId}&roleId=${roleIds}`)
  },

  deleteUserByIdList(idList) {
    return request.delete('/admin/acl/user/batchRemove', idList)
  }
}
